package com.retallife.user.service.ShoppingCart.Impl;

import com.retallife.user.dao.ShoppingCart.ShoppingCartMapper;
import com.retallife.user.pojo.ShoppingCart.UserAddShoppingCartVo;
import com.retallife.user.pojo.ShoppingCart.UserShoppingCartGoodsNameVo;
import com.retallife.user.pojo.ShoppingCart.UserShoppingCartVo;
import com.retallife.user.service.ShoppingCart.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShoppingCartServiceImpl implements ShoppingCartService {
    @Autowired
    ShoppingCartMapper shoppingCartMapper;

    /**
     * 查询购物车中的商品
     * @return 是否查询成功
     */
    public List<UserShoppingCartVo> FindAllShoppingCartGoods() {
        return shoppingCartMapper.FindAllShoppingCartGoods();
    }

    /**
     * 查询购物车中的商品名字
     * @param userShoppingCartGoodsNameVo
     * @return 是否查询成功
     */
    public List<UserShoppingCartVo> FindShoppingCartGoodsName(UserShoppingCartGoodsNameVo userShoppingCartGoodsNameVo) {
        return shoppingCartMapper.FindShoppingCartGoodsName(userShoppingCartGoodsNameVo);
    }

    /**
     * 往增加购物车中的商品
     * @param userAddShoppingCartVo
     * @return 是否增加成功
     */
    public int AddShoppingCartGoods(UserAddShoppingCartVo userAddShoppingCartVo) {
        return shoppingCartMapper.AddShoppingCartGoods(userAddShoppingCartVo);
    }

    /**
     * 删除购物车中的商品
     * @param userShoppingCartGoodsNameVo
     * @return 是否删除成功
     */
    public int DeleteShoppingCartGoods(UserShoppingCartGoodsNameVo userShoppingCartGoodsNameVo){
        return shoppingCartMapper.DeleteShoppingCartGoods(userShoppingCartGoodsNameVo);
    }
}
